package org.dahuatech.ssh.action;

import java.util.Map;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.dahuatech.ssh.common.utils.ConstantsUtils;
import org.dahuatech.ssh.entity.account.Authority;
import org.dahuatech.ssh.entity.account.User;
import org.dahuatech.ssh.service.account.AccountManager;
import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
@InterceptorRefs({  
	@InterceptorRef("defaultInterceporStack")
}) 
public class IndexAction extends ActionSupport{
	private AccountManager accountManager;
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		User user=(User)ServletActionContext.getRequest().getSession().getAttribute(ConstantsUtils.USER);
		Map<Long,Authority> menuItems=accountManager.getAuthorityMenuItem(user);
		ServletActionContext.getRequest().getSession().setAttribute("menus", menuItems);
		return ActionSupport.SUCCESS;
	}
	@Autowired
	public void setAccountManager(AccountManager accountManager) {
		this.accountManager = accountManager;
	}
	public AccountManager getAccountManager() {
		return accountManager;
	}

}
